
package modelo.bo.cmd.contato;

import java.io.IOException;
import java.sql.*;
import javax.servlet.http.*;
import modelo.bo.cmd.Acao;
import modelo.dao.impl.*;
import modelo.dao.inter.IGenericoDAO;
import modelo.dao.util.ConexaoMySQL;

public class CarregarFormContato extends Acao {
	
	public CarregarFormContato() {
		super();	
	}

	@Override
	public void init(HttpServletRequest request) {
		super.pagina = "/pages/contato/cadastro-contato.jsp";
	}

	@Override
	public boolean executar(HttpServletRequest request, HttpServletResponse response) throws IOException {			

		Connection conn = null;
		IGenericoDAO ig = null;
		
		try {
			
			conn = ConexaoMySQL.getConnection();
			ig = new GrupoImpl(conn);	
					
			request.setAttribute("grupos", ig.buscarTodos());
			
			ig  = new OperadoraImpl(conn);
			
			request.setAttribute("operadoras", ig.buscarTodos());
			
		} 
		catch (SQLException e) {
			e.printStackTrace();
			request.setAttribute("msg", e.getMessage());
		}
		
		return super.efetuou;
	}

	@Override
	public String retornaPagina() {
		return super.pagina;
	}

}
